/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.bis.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.jeesite.modules.bis.entity.BisSignIn;
import com.jeesite.modules.bis.dao.BisSignInDao;

/**
 * 签到记录Service
 * @author Zhangning
 * @version 2019-10-13
 */
@Service
@Transactional(readOnly=true)
public class BisSignInService extends CrudService<BisSignInDao, BisSignIn> {
	
	/**
	 * 获取单条数据
	 * @param bisSignIn
	 * @return
	 */
	@Override
	public BisSignIn get(BisSignIn bisSignIn) {
		return super.get(bisSignIn);
	}
	
	/**
	 * 查询分页数据
	 * @param bisSignIn 查询条件
	 * @param bisSignIn.page 分页对象
	 * @return
	 */
	@Override
	public Page<BisSignIn> findPage(BisSignIn bisSignIn) {
		return super.findPage(bisSignIn);
	}
	
	/**
	 * 保存数据（插入或更新）
	 * @param bisSignIn
	 */
	@Override
	@Transactional(readOnly=false)
	public void save(BisSignIn bisSignIn) {
		super.save(bisSignIn);
	}
	
	/**
	 * 更新状态
	 * @param bisSignIn
	 */
	@Override
	@Transactional(readOnly=false)
	public void updateStatus(BisSignIn bisSignIn) {
		super.updateStatus(bisSignIn);
	}
	
	/**
	 * 删除数据
	 * @param bisSignIn
	 */
	@Override
	@Transactional(readOnly=false)
	public void delete(BisSignIn bisSignIn) {
		super.delete(bisSignIn);
	}

	/**
	 * 获取连续签到天数
	 * @param id
	 * @return
	 */
	public Integer getSeriesCount(String id) {
		Integer result = dao.getSeriesCount(id);
		return result == null ? 0 : result;
	}

	/**
	 * 获取总签到天数
	 * @param id
	 * @return
	 */
	public int getTotalCount(String id) {
		return dao.getTotalCount(id);
	}

	/**
	 * 获取今日是否签到
	 * @param id
	 * @return
	 */
	public boolean getTodaySignState(String id) {
		Integer result = dao.getTodaySignState(id);
		return result != null;
	}
}